# Contributor: kohnish <kohnish@gmx.com>
# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=buildah
pkgver=1.34.1
pkgrel=3
pkgdesc="tool that facilitates building OCI container images"
url="https://github.com/containers/buildah"
license="Apache-2.0"
arch="all"
depends="oci-runtime shadow-subids slirp4netns containers-common"
makedepends="go go-md2man lvm2-dev gpgme-dev libseccomp-dev btrfs-progs-dev bash"
subpackages="$pkgname-doc"
options="!check" # tests require root privileges
source="https://github.com/containers/buildah/archive/v$pkgver/buildah-$pkgver.tar.gz
	basename.patch
	"

# secfixes:
#   1.34.0-r1:
#     - CVE-2023-48795
#   1.28.0-r0:
#     - CVE-2022-2990
#   1.21.3-r0:
#     - CVE-2021-3602
#   1.19.4-r0:
#     - CVE-2021-20206
#   1.14.4-r0:
#     - CVE-2020-10696

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	# https://github.com/mattn/go-sqlite3/issues/1164
	export CGO_CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"

	GIT_COMMIT="$pkgver" make buildah
	GIT_COMMIT="$pkgver" make -C docs GOMD2MAN="$(which go-md2man)"
}

package() {
	GIT_COMMIT="$pkgver" make install PREFIX=/usr DESTDIR="$pkgdir"
}

sha512sums="
2d229ead1149b66d1b7d91f596809e97e5316356ab0997ea335eb3e246ed8bc6879e0e260bb478b4d7ec7c42c7dbf33d0e91086a34e89a3b79eb27322da06c1e  buildah-1.34.1.tar.gz
640526de31a5eb21112c3d3fd30ce78331e5f5998166c9af9405ebad919a9a895ee82e3eed7067c2ce7e3e558e31907398fec1ad895be708e9f8ada696076216  basename.patch
"
